package com.gongzhongzhisheng.robot.controller;

import java.util.Arrays;

public class WeChatConnectValidateUtil {  
    //Token 和微信后台接入接口的token一致  
    private final static String TOKEN="gongzhongzhisheng123";    
      
   public static boolean checkSignature(String signature,String timestamp,String nonce){  
       //System.out.println("进checkSignature");  
       String arr[]=new String[]{TOKEN,timestamp,nonce};  
         
       //排序  
       Arrays.sort(arr);  
         
       //生成字符串  
       StringBuffer content=new StringBuffer();  
       for(int i=0;i<arr.length;i++){  
           content.append(arr[i]);     
       }  
         
       //sha1加密  
       String temp=EncryptionUtil.getSha1(content.toString());  
         
      // System.out.println(temp+" "+signature.equals(temp));  
       return signature.equals(temp);  
}  
}
